# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

_realname=farstream
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.2.8
pkgrel=2
pkgdesc="Farstream (formerly Farsight) - Audio/Video Communications Framework (mingw-w64)"
arch=('any')
url="https://www.freedesktop.org/wiki/Software/Farstream"
license=('LGPL')
options=('staticlibs' 'strip')
depends=("${MINGW_PACKAGE_PREFIX}-gst-plugins-base" "${MINGW_PACKAGE_PREFIX}-libnice")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "gtk-doc")
source=(https://freedesktop.org/software/${_realname}/releases/${_realname}/${_realname}-${pkgver}.tar.gz{,.asc}
        0001-farstream-0.2.4.patch
        0002-give-cc-to-gir-scanner.all.patch)
sha256sums=('2b3b9c6b4f64ace8c83e03d1da5c5a2884c1cae10b35471072b574201ab38908'
            'SKIP'
            '3d85a6c236ce5af088e98c5afc95e5969cac27050cffcc4b1963ccfb004dbbfe'
            'd6001b52ababf3358a4ddfd710dffc1c75e79e662c618de80efacb5806314544')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}/0001-farstream-0.2.4.patch"
  patch -p1 -i "${srcdir}/0002-give-cc-to-gir-scanner.all.patch"

  WANT_AUTOMAKE=latest autoreconf --force --install
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --enable-introspection

  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make check
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install

  rm -f ${pkgdir}${MINGW_PREFIX}/lib/gstreamer*/*.a
  rm -f ${pkgdir}${MINGW_PREFIX}/lib/farstream*/*.a
}
